package src._5;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by didi on 26/02/2018.
 */
interface A {
    void x();
}
class B implements A{
    public void x(){}
    public void y(){}
}
class C extends B{
    public void x(){}
}

public class Foo {
    public static void main(String[] args) {
        List<A> list = new ArrayList<>();
        list.add(new B());
        list.add(new C());
        for(A a: list){
            a.x();
//            a.y(); //面向接口编程, 只有接口方法可以调用.
        }
    }
}